
--
-- PIC
--
  CREATE TABLE "PIC" 
   (	"ID" NUMBER(38,0) NOT NULL ENABLE,
	"FILENAME" VARCHAR2(500 CHAR),
	"FILEFULLNAME" VARCHAR2(500 CHAR),
	"ORIGNAME" VARCHAR2(500 CHAR),
	CONSTRAINT "PK_PIC" PRIMARY KEY ("ID") ENABLE
   );
--
-- PICDATA
--
  CREATE TABLE "PICDATA" 
   (	"ID" NUMBER NOT NULL ENABLE,
	"FILEDATA" BLOB,
	CONSTRAINT "PK_PICDATA" PRIMARY KEY ("ID") ENABLE
   );
--
-- REMARK
--
  CREATE TABLE "REMARK" 
   (	"ID" NUMBER(38,0) NOT NULL ENABLE,
	"REMARK1" VARCHAR2(500 CHAR),
	"USERID" VARCHAR2(50 CHAR),
	CONSTRAINT "PK_REMARK" PRIMARY KEY ("ID") ENABLE
   );
--
-- REMARKGROUP
--
  CREATE TABLE "REMARKGROUP" 
   (	"ID" NUMBER(38,0) NOT NULL ENABLE,
	"REMARKID" NUMBER(38,0),
	"GROUPNAME" VARCHAR2(500 CHAR),
	"USERID" VARCHAR2(50 CHAR),
	CONSTRAINT "PK_REMARKGROUP" PRIMARY KEY ("ID") ENABLE
   );
--
-- TYPE
--
  CREATE TABLE "TYPE" 
   (	"ID" NUMBER(38,0) NOT NULL ENABLE,
	"TYPENAME" VARCHAR2(500 CHAR),
	"USERID" VARCHAR2(50 CHAR),
	CONSTRAINT "PK_TYPE" PRIMARY KEY ("ID") ENABLE
   );
--
-- PICTYPEREMARKGROUP
--
  CREATE TABLE "PICTYPEREMARKGROUP" 
   (	"ID" NUMBER(38,0) NOT NULL ENABLE,
	"TYPEID" NUMBER(38,0),
	"REMARKID" NUMBER(38,0),
	"REMARKGROUPID" NUMBER(38,0),
	"PICID" NUMBER(38,0),
	"USERID" VARCHAR2(50 CHAR),
	CONSTRAINT "PK_PICTYPEREMARKGROUP" PRIMARY KEY ("ID") ENABLE
   );
--
-- TYPEREMARK
--
  CREATE TABLE "TYPEREMARK" 
   (	"ID" NUMBER(38,0) NOT NULL ENABLE,
	"TYPEID" NUMBER(38,0),
	"REMARKID" NUMBER(38,0),
	"USERID" VARCHAR2(50 CHAR),
	CONSTRAINT "PK_TYPEREMARK" PRIMARY KEY ("ID") ENABLE
   );
--
-- USER_LOG
--
  CREATE TABLE "USER_LOG" 
   (	"ID" NUMBER(38,0) NOT NULL ENABLE,
	"USERID" VARCHAR2(50 CHAR),
	"ODATE" DATE,
	"CONTENT" VARCHAR2(2000 CHAR),
	CONSTRAINT "PK_USER_LOG" PRIMARY KEY ("ID") ENABLE
   );
--
-- INSERT_PIC
--
  CREATE OR REPLACE TRIGGER "INSERT_PIC"
  BEFORE INSERT ON "PIC"FOR EACH ROW
  declare
  -- local variables here
  pic_id number;
begin
  Select pic_seq.nextval into pic_id from dual;
  :new.id := pic_id;
end INSERT_PIC;

/
--
-- INSERT_PICTYPEREMARKGROUP
--
  CREATE OR REPLACE TRIGGER "INSERT_PICTYPEREMARKGROUP"
  BEFORE INSERT ON "PICTYPEREMARKGROUP"FOR EACH ROW
  declare
  -- local variables here
  PICTYPEREMARKGROUP_id number;
begin
  Select PICTYPEREMARKGROUP_seq.nextval into PICTYPEREMARKGROUP_id from dual;
  :new.id := PICTYPEREMARKGROUP_id;
end INSERT_PICTYPEREMARKGROUP;

/
--
-- INSERT_REMARK
--
  CREATE OR REPLACE TRIGGER "INSERT_REMARK"
  BEFORE INSERT ON "REMARK"FOR EACH ROW
  declare
  -- local variables here
  remark_id number;
begin
  Select remark_seq.nextval into remark_id from dual;
  :new.id := remark_id;
end INSERT_REMARK;

/
--
-- INSERT_REMARKGROUP
--
  CREATE OR REPLACE TRIGGER "INSERT_REMARKGROUP"
  BEFORE INSERT ON "REMARKGROUP"FOR EACH ROW
  declare
  -- local variables here
  REMARKGROUP_id number;
begin
  Select REMARKGROUP_seq.nextval into REMARKGROUP_id from dual;
  :new.id := REMARKGROUP_id;
end INSERT_REMARKGROUP;

/
--
-- INSERT_TYPE
--
  CREATE OR REPLACE TRIGGER "INSERT_TYPE"
  BEFORE INSERT ON "TYPE"FOR EACH ROW
  declare
  -- local variables here
  type_id number;
begin
  Select type_seq.nextval into type_id from dual;
  :new.id := type_id;
end INSERT_type;

/
--
-- INSERT_TYPEREMARK
--
  CREATE OR REPLACE TRIGGER "INSERT_TYPEREMARK"
  BEFORE INSERT ON "TYPEREMARK"FOR EACH ROW
  declare
  -- local variables here
  TYPEREMARK_id number;
begin
  Select TYPEREMARK_seq.nextval into TYPEREMARK_id from dual;
  :new.id := TYPEREMARK_id;
end INSERT_TYPEREMARK;

/
--
-- INSERT_USER_LOG
--
  CREATE OR REPLACE TRIGGER "INSERT_USER_LOG"
  BEFORE INSERT ON "USER_LOG"FOR EACH ROW
  declare
  -- local variables here
  USER_LOG_id number;
begin
  Select USER_LOG_seq.nextval into USER_LOG_id from dual;
  :new.id := USER_LOG_id;
end INSERT_USER_LOG;

/
--
-- IX_FK_PTRG_PIC
--
  CREATE INDEX "IX_FK_PTRG_PIC" ON "PICTYPEREMARKGROUP" ("PICID");
--
-- IX_FK_PTRG_REMARK
--
  CREATE INDEX "IX_FK_PTRG_REMARK" ON "PICTYPEREMARKGROUP" ("REMARKID");
--
-- IX_FK_PTRG_REMARKGROUP
--
  CREATE INDEX "IX_FK_PTRG_REMARKGROUP" ON "PICTYPEREMARKGROUP" ("REMARKGROUPID");
--
-- IX_FK_PTRG_TYPE
--
  CREATE INDEX "IX_FK_PTRG_TYPE" ON "PICTYPEREMARKGROUP" ("TYPEID");
--
-- IX_FK_REMARKGROUP_REMARK
--
  CREATE INDEX "IX_FK_REMARKGROUP_REMARK" ON "REMARKGROUP" ("REMARKID");
--
-- IX_FK_TYPEREMARK_REMARK
--
  CREATE INDEX "IX_FK_TYPEREMARK_REMARK" ON "TYPEREMARK" ("REMARKID");
--
-- IX_FK_TYPEREMARK_TYPE
--
  CREATE INDEX "IX_FK_TYPEREMARK_TYPE" ON "TYPEREMARK" ("TYPEID");
--
-- FK_PTRG_PIC
--
ALTER TABLE "PICTYPEREMARKGROUP" ADD CONSTRAINT "FK_PTRG_PIC" FOREIGN KEY ("PICID") REFERENCES "PIC"("ID") ON DELETE CASCADE ENABLE;

--
-- FK_PTRG_REMARK
--
ALTER TABLE "PICTYPEREMARKGROUP" ADD CONSTRAINT "FK_PTRG_REMARK" FOREIGN KEY ("REMARKID") REFERENCES "REMARK"("ID") ON DELETE CASCADE ENABLE;

--
-- FK_PTRG_REMARKGROUP
--
ALTER TABLE "PICTYPEREMARKGROUP" ADD CONSTRAINT "FK_PTRG_REMARKGROUP" FOREIGN KEY ("REMARKGROUPID") REFERENCES "REMARKGROUP"("ID") ON DELETE CASCADE ENABLE;

--
-- FK_PTRG_TYPE
--
ALTER TABLE "PICTYPEREMARKGROUP" ADD CONSTRAINT "FK_PTRG_TYPE" FOREIGN KEY ("TYPEID") REFERENCES "TYPE"("ID") ON DELETE CASCADE ENABLE;

--
-- FK_REMARKGROUP_REMARK
--
ALTER TABLE "REMARKGROUP" ADD CONSTRAINT "FK_REMARKGROUP_REMARK" FOREIGN KEY ("REMARKID") REFERENCES "REMARK"("ID") ON DELETE CASCADE ENABLE;

--
-- FK_TYPEREMARK_REMARK
--
ALTER TABLE "TYPEREMARK" ADD CONSTRAINT "FK_TYPEREMARK_REMARK" FOREIGN KEY ("REMARKID") REFERENCES "REMARK"("ID") ON DELETE CASCADE ENABLE;

--
-- FK_TYPEREMARK_TYPE
--
ALTER TABLE "TYPEREMARK" ADD CONSTRAINT "FK_TYPEREMARK_TYPE" FOREIGN KEY ("TYPEID") REFERENCES "TYPE"("ID") ON DELETE CASCADE ENABLE;

